#ifndef ANIMATION_H
#define ANIMATION_H

#include <vector>
using namespace std;

class Sprite;
class Texture;

class Animation
{
private:
	int id;
	vector<Sprite*> sprites;
	int curSprite;

	float nextSpriteDelay;
	bool isStatic;					//Static frame or animation

public:
	Animation();
	Animation(int id);
	void AddSprite(Sprite* sprite);
	void RemoveSprite(int index);
	bool Update();
	void Render(int x, int y, float deep);
	void Render(int x, int y, float alpha, float deep);
	void Render(int x, int y, float xScale, float yScale, float angle, float alpha,float deep);

	// auto generate module and sprite in case these sprite has one module and has same size and render time.
	void GenerateAuto(Texture* texture, int spriteWidth, int spriteHeight, 
		int numColumn, int fromIndex, int toIndex, float renderTime);
	void GenerateAuto(Texture* texture, int xBegin, int yBegin, int spriteWidth, int spriteHeight, 
		int numColumn, int fromIndex, int toIndex, float renderTime);

	void SetSpriteIndex(bool isStatic, int index=0);

	~Animation();

	int GetID(){return id;}
};

#endif